package com.atguigu.tingshu.user.mapper;

import com.atguigu.tingshu.model.user.UserInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserInfoMapper extends BaseMapper<UserInfo> {

    /**
     * 更新用户会员状态
     */
    @Update(" UPDATE user_info\n" +
            "\t\tSET is_vip = 0,\n" +
            "\t\tupdate_time = NOW()\n" +
            "\t\tWHERE is_vip = 1\n" +
            "\t\tAND vip_expire_time < NOW()\n" +
            "\t\tAND is_deleted = 0 ")
    void updateVipExpireStatus();
}
